<?php

class ProviderQuery{
	/*
	 *  es. ProviderQuery di hopey.netfonds.com
	 *  
	 *                 +------------------+-------+----------+ 
	 *                 |  timestamp(UTC)  | price | quantity |
	 *                 +==================+=======+==========+
	 *  $this->row[0]= |28/02/15 15:30:00 | 15.34 |  1200    |
	 *                 +------------------+-------+----------+ 
	 *  $this->row[1]= |28/02/15 15:30:00 | 15.33 |  1400    |
	 *                 +------------------+-------+----------+ 
	 *  $this->row[2]= |28/02/15 15:30:00 | 15.32 |   200    |
	 *                 +------------------+-------+----------+ 
	 *  $this->row[3]= |28/02/15 15:30:01 | 15.33 |  2900    |
	 *                 +------------------+-------+----------+
	 *       ......        ......           ....    .... 
	 *                 
	 *                 
	 *                  
	 *  es. ProviderQuery di finance.google.com
	 *  
	 *                 +------------------+-------+-------+-------+-------+----------+ 
	 *                 |  timestamp(UTC)  | open  | close | max   | min   | quantity |
	 *                 +==================+=======+=======+=======+=======+==========+
	 *  $this->row[0]= |28/02/15 15:30:00 | 15.34 | 15.34 | 15.34 | 15.32 |  120000  |
	 *                 +------------------+-------+-------+-------+-------+----------+ 
	 *  $this->row[1]= |28/02/15 15:31:00 | 15.33 | 15.33 | 15.33 | 15.11 |  234000  |
	 *                 +------------------+-------+-------+-------+-------+----------+ 
	 *  $this->row[2]= |28/02/15 15:32:00 | 15.22 | 15.32 | 15.34 | 15.20 |  200400  |
	 *                 +------------------+-------+-------+-------+-------+----------+ 
	 *  $this->row[3]= |28/02/15 15:33:00 | 15.43 | 15.33 | 15.45 | 15.41 |  146900  |
	 *                 +------------------+-------+-------+-------+-------+----------+ 
	 *       ......        ......           ....    ....    ....    ....    .... 
	 *                 
	 */

	protected $row = array();
	
	public function __construct($array = NULL){
		if(isset($array))
			$this->row = $array;
	}
	
	//da invocare in provider<derived> cosi': 
	// x->Feed(tsObj, {"price" => 114.2, "quantity" => 100})
	public function Feed($ts, $rowValues){
		$currRow = array();
		
		$currRow["ts"] = $ts;
		foreach ($rowValues as $field => $value)
			$currRow[$field] = $value;
		
		$this->row[] = $currRow;
	}
	
	public function GetRow($i){
		return $this->row[$i];
	}
}

?>
